Clean up save/restore state record handling. No need for Python to
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 4 Apr 2007 15:34:56 +0000 (16:34 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 4 Apr 2007 15:34:56 +0000 (16:34 +0100)
read out the 'p2m size' field. Also that field is not needed at all
for HVM guests.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/libxc/ia64/xc_ia64_linux_restore.c
tools/libxc/xc_hvm_save.c
tools/libxc/xc_linux_restore.c
tools/libxc/xenguest.h
tools/python/xen/xend/XendCheckpoint.py
tools/xcutils/xc_restore.c

index 8140908f411abaed3daf06eb1e4bebbc6f2958b5..357e89796de3c011fb325bbbdfafdb91f0351427 100644 (file)
@@ -59,7 +59,7 @@ read_page(int xc_handle, int io_fd, uint32_t dom, unsigned long pfn)
 }
 
 int
-xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, unsigned long p2msize,
+xc_linux_restore(int xc_handle, int io_fd, uint32_t dom,
                  unsigned int store_evtchn, unsigned long *store_mfn,
                  unsigned int console_evtchn, unsigned long *console_mfn)
 {
@@ -81,11 +81,14 @@ xc_linux_restore(int xc_handle, int io_fd, uint32_t dom, unsigned long p2msize,
     /* A temporary mapping of the guest's start_info page. */
     start_info_t *start_info;
 
-    p2m_size = p2msize;
-
     /* For info only */
     nr_pfns = 0;
 
+    if ( !read_exact(io_fd, &p2m_size, sizeof(unsigned long)) )
+    {
+        ERROR("read: p2m_size");
+        goto out;
+    }
     DPRINTF("xc_linux_restore start: p2m_size = %lx\n", p2m_size);
 
     if (!read_exact(io_fd, &ver, sizeof(unsigned long))) {
index 12d2226c8119e5541f558a0ca8867d3ebc42fca1..1b3ad5d356fb41bb9ecbaabe06d91ccacf1b44c0 100644 (file)
@@ -434,13 +434,6 @@ int xc_hvm_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
         goto out;
     }
 
-    /* Start writing out the saved-domain record. */
-    if ( !write_exact(io_fd, &max_pfn, sizeof(unsigned long)) )
-    {
-        ERROR("write: max_pfn");
-        goto out;
-    }
-
     for ( ; ; )
     {
         unsigned int prev_pc, sent_this_iter, N, batch;
index c9cc196763e12c4eff768cb4f5161627b5ea5be4..02342b45099944ef9dd480cc185ab01cb96ced40 100644 (file)
@@ -142,7 +142,6 @@ static int uncanonicalize_pagetable(int xc_handle, uint32_t dom,
 
 
 int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom,
-                     unsigned long p2msize,
                      unsigned int store_evtchn, unsigned long *store_mfn,
                      unsigned int console_evtchn, unsigned long *console_mfn)
 {
@@ -194,11 +193,14 @@ int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom,
     unsigned int max_vcpu_id = 0;
     int new_ctxt_format = 0;
 
-    p2m_size    = p2msize;
-
     /* For info only */
     nr_pfns = 0;
 
+    if ( !read_exact(io_fd, &p2m_size, sizeof(unsigned long)) )
+    {
+        ERROR("read: p2m_size");
+        goto out;
+    }
     DPRINTF("xc_linux_restore start: p2m_size = %lx\n", p2m_size);
 
     /*
index c5bfa9c5d9e8c849a355c5e17dd0e8302fc4b459..988c85feb64c406c736f337cba4a94515f43e932 100644 (file)
@@ -43,14 +43,11 @@ int xc_hvm_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
  * @parm xc_handle a handle to an open hypervisor interface
  * @parm fd the file descriptor to restore a domain from
  * @parm dom the id of the domain
- * @parm p2m_size number of pages the guest has (i.e. number entries in P2M)
- * @parm max_nr_pfns domains maximum real memory allocation, in pages
  * @parm store_evtchn the store event channel for this domain to use
  * @parm store_mfn returned with the mfn of the store page
  * @return 0 on success, -1 on failure
  */
 int xc_linux_restore(int xc_handle, int io_fd, uint32_t dom,
-                     unsigned long p2m_size,
                      unsigned int store_evtchn, unsigned long *store_mfn,
                      unsigned int console_evtchn, unsigned long *console_mfn);
 
index 7dcfed58b4ae77800fbc8144d864421105680250..0be79084e6cc7aac5c10c617ab10cec70bd81293 100644 (file)
@@ -201,19 +201,11 @@ def restore(xd, fd, dominfo = None, paused = False):
         pae  = 0
 
     try:
-        l = read_exact(fd, sizeof_unsigned_long,
-                       "not a valid guest state file: pfn count read")
-        p2m_size = unpack("L", l)[0]    # native sizeof long
-
-        if p2m_size > 16*1024*1024:     # XXX 
-            raise XendError(
-                "not a valid guest state file: pfn count out of range")
-
         shadow = dominfo.info['shadow_memory']
-        log.debug("restore:shadow=0x%x, _static_max=0x%x, _static_min=0x%x, "
-                  "p2m_size=0x%x.", dominfo.info['shadow_memory'],
+        log.debug("restore:shadow=0x%x, _static_max=0x%x, _static_min=0x%x, ",
+                  dominfo.info['shadow_memory'],
                   dominfo.info['memory_static_max'],
-                  dominfo.info['memory_static_min'], p2m_size)
+                  dominfo.info['memory_static_min'])
 
         balloon.free(xc.pages_to_kib(nr_pfns) + shadow * 1024)
 
@@ -223,7 +215,7 @@ def restore(xd, fd, dominfo = None, paused = False):
         xc.domain_setmaxmem(dominfo.getDomid(), dominfo.getMemoryMaximum())
 
         cmd = map(str, [xen.util.auxbin.pathTo(XC_RESTORE),
-                        fd, dominfo.getDomid(), p2m_size,
+                        fd, dominfo.getDomid(),
                         store_port, console_port, int(is_hvm), pae, apic])
         log.debug("[xc_restore]: %s", string.join(cmd))
 
index 3309efffa1c52d7f44a230337f5bb1c2e8702f1b..fc1a59073e2180ebef90f2832a5901ebc5240d64 100644 (file)
@@ -21,10 +21,10 @@ main(int argc, char **argv)
     unsigned int xc_fd, io_fd, domid, store_evtchn, console_evtchn;
     unsigned int hvm, pae, apic;
     int ret;
-    unsigned long p2m_size, store_mfn, console_mfn;
+    unsigned long store_mfn, console_mfn;
 
-    if ( argc != 9 )
-        errx(1, "usage: %s iofd domid p2m_size store_evtchn "
+    if ( argc != 8 )
+        errx(1, "usage: %s iofd domid store_evtchn "
              "console_evtchn hvm pae apic", argv[0]);
 
     xc_fd = xc_interface_open();
@@ -33,18 +33,18 @@ main(int argc, char **argv)
 
     io_fd = atoi(argv[1]);
     domid = atoi(argv[2]);
-    p2m_size = atoi(argv[3]);
-    store_evtchn = atoi(argv[4]);
-    console_evtchn = atoi(argv[5]);
-    hvm  = atoi(argv[6]);
-    pae  = atoi(argv[7]);
-    apic = atoi(argv[8]);
+    store_evtchn = atoi(argv[3]);
+    console_evtchn = atoi(argv[4]);
+    hvm  = atoi(argv[5]);
+    pae  = atoi(argv[6]);
+    apic = atoi(argv[7]);
 
     if ( hvm )
-        ret = xc_hvm_restore(xc_fd, io_fd, domid, store_evtchn,
-                             &store_mfn, pae, apic);
+        ret = xc_hvm_restore(xc_fd, io_fd, domid,
+                             store_evtchn, &store_mfn,
+                             pae, apic);
     else
-        ret = xc_linux_restore(xc_fd, io_fd, domid, p2m_size,
+        ret = xc_linux_restore(xc_fd, io_fd, domid,
                                store_evtchn, &store_mfn,
                                console_evtchn, &console_mfn);